 
#include <string.h>
#include <math.h>
#include "system.h"
#include "f1c100s_de.h"
#include "f1c100s_timer.h"
#include "f1c100s_intc.h"
#include "f1c100s_gpio.h"
#include "f1c100s_pwm.h"
#include "f1c100s_uart.h"
#include "arm32.h"
#include "disp.h"

#include "InfoNES_System.h"
#include "InfoNES.h"

int main(void)
{
    system_init();            // Initialize clocks, mmu, cache, uart, ...
    arm32_interrupt_enable(); // Enable interrupts
    printf("\r\napp [display] run. compiled_time %s %s\r\n", __DATE__, __TIME__);
    disp_rgb_init();
    printf("sizeof short:%d", sizeof(WORD));

    while (0) // test colors
    {
        extern WORD NesPalette[64];
        disp_clear(0xffff0000);
        delay_soft(100);
        disp_clear(0xff00ff00);
        delay_soft(100);
        disp_clear(0xff0000ff);
        delay_soft(100);

        for (int i = 0; i < 64; i++)
        {
            disp_clear(ARGB(NesPalette[i]));
            delay_soft(100);
        }
    }

    while (1)
    {
        if (InfoNES_Load(NULL) == 0)//test ok.
        {
            printf("nes run.\r\n");
            InfoNES_Main();
        }
    }
}
